package top.i51213.fastaction.tuple;

public abstract class Tuple {

    public static <A, B> Tuple2<A, B> New(A a, B b) {
        return new Tuple2<>(a, b);
    }

    public static <A, B, C> Tuple3<A, B, C> New(A a, B b, C c) {
        return new Tuple3<>(a, b, c);
    }

    public static <A, B, C, D> Tuple4<A, B, C, D> New(A a, B b, C c, D d) {
        return new Tuple4<>(a, b, c, d);
    }

    @SuppressWarnings("unused")
    public abstract int dimensionCount();

    /***
     *
     * @param index start from 1
     * @return
     */
    @SuppressWarnings("unused")
    public abstract Object get(int index);

    public static String toString(Object... objs) {
        StringBuilder sb = new StringBuilder();
        sb.append("Tuple{");
        for (int i = 0; i < objs.length - 1; i++) {
            sb.append(objs[i]);
        }
        if (objs.length > 0) {
            sb.append(objs[objs.length - 1]);
        }
        return sb.toString();
    }
}
